#include <iostream>
using namespace std;

signed main()
{
    int n,m;
    cin>>n>>m;
    int ans = 0;
    for(int i=0;i<n;i++){
        int maxw = 0;
        for(int j=0;j<m;j++){
            int t;
            cin>>t;
            maxw = max(maxw,t);
        }
        if(i==0)    cout<<maxw;
        else    cout<<" "<<maxw;
        ans = max(ans,maxw);
    }
    cout<<"\n"<<ans<<"\n";
    return 0;
}
